package com.last.controller;

import com.last.entity.Order;
import com.last.entity.Result;
import com.last.service.IOrderService;
import com.last.service.impl.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService iOrderService;

    @RequestMapping("/saveOrder")
    public Result<Order> saveOrder(@RequestBody Order order){
        return iOrderService.saveOrder(order);
    }


    @RequestMapping("/releaseOrder")
    public Result<Order> releaseOrder(@RequestBody String orderId){
        return iOrderService.releaseOrder(orderId);
    }

    @RequestMapping("/status")
    public Result status(@RequestBody Order order){

        boolean b = iOrderService.updateById(order);

        return new Result(b,b?"修改成功":"修改失败");
    }

    @RequestMapping("findOrderInfo")
    public Order findOrderInfo(String orderId){

        return iOrderService.getById(orderId);
    }

}
